package chatRoom.network;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public abstract class Connection implements Runnable
{
	private Socket socket_;
	
	public void setSocket(Socket socket)
	{
		socket_ = socket;
	}
	
	public Socket getSocket()
	{
		return socket_;
	}
	
	public BufferedReader getInput()
	{
		BufferedReader reader = null;
		try 
		{
			reader = new BufferedReader(new InputStreamReader(socket_.getInputStream()));
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
		return reader;
	}
	
	public PrintWriter getOutput()
	{
		PrintWriter writer = null;
		try 
		{
			writer = new PrintWriter(socket_.getOutputStream(), true);
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
		return writer;
	}
}
